Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support node esmodule and mf-manifest esmodule (#2934) #3013

Merged
merged 7 commits into from
Sep 29, 2024

Conversation

ScriptedAlchemy
Copy link
Member

Description

Supports importing remote files in esm format in the node environment

Related Issue

module-federation/vite#73

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

Co-authored-by: 张洪恩 <zhanghongen@bwcj.com>
Co-authored-by: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com>
Copy link

changeset-bot bot commented Sep 28, 2024

⚠️ No Changeset found

Latest commit: f41913a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Sep 28, 2024

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit c529a72
🔍 Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/66f87cc10f1c970008c41ab6
😎 Deploy Preview https://deploy-preview-3013--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Sep 28, 2024

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit f41913a
🔍 Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/66f8ea4a4485ed0008b012eb
😎 Deploy Preview https://deploy-preview-3013--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ScriptedAlchemy ScriptedAlchemy marked this pull request as ready for review September 29, 2024 05:43
# Conflicts:
#	pnpm-lock.yaml
Copy link
Contributor

@squadronai squadronai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Here is a concise summary of the pull request:

This pull request adds support for importing remote files in ESM format in the Node.js environment. The key changes include:

  • Updating the type property of the moduleInfo object to use the remoteInfo.type value, allowing for more flexible handling of different module types (global or esmodule).
  • Introducing a new type property to the remoteInfo object, which is then passed to the loadScriptNode function to handle ESM-formatted remote entries.
  • Updating the script type to 'module' if the provided attributes indicate an ESM format, and adding the ability to apply custom attributes to the created script element.
  • Adding a new loadModule function to handle the loading and evaluation of ESM modules, and updating the createScriptNode function to support ESM scripts by leveraging the loadModule function.
  • Introducing a conditional statement that sets the ssrRemoteEntryType property based on the type field of the ssrRemoteEntry object, allowing for both CommonJS and ESM formats to be handled.

These changes improve the flexibility and functionality of the module federation runtime, enabling support for ESM-formatted remote files in the Node.js environment.

File Summaries
File Summary
packages/runtime/src/plugins/generate-preload-assets.ts The code changes introduce support for importing remote files in esm format in the node environment. The primary modification is updating the type property of the moduleInfo object to use the remoteInfo.type value, which can be either 'global' or 'esmodule', allowing for more flexible handling of different module types.
packages/runtime/src/utils/load.ts The code changes introduce support for importing remote files in ESM format in the Node.js environment. The key modifications include adding a new type property to the remoteInfo object, which is then passed to the loadScriptNode function, allowing it to handle ESM-formatted remote entries.
packages/sdk/src/dom.ts The code changes introduce support for importing remote files in ESM format in the Node environment. The key modifications include updating the script type to 'module' if the provided attributes indicate an ESM format, and adding the ability to apply custom attributes to the created script element.
packages/sdk/src/generateSnapshotFromManifest.ts The code changes introduce support for importing remote files in ESM format in the Node.js environment. The primary modification is the addition of a conditional statement that sets the ssrRemoteEntryType property based on the type field of the ssrRemoteEntry object, allowing for both CommonJS and ESM formats to be handled.
packages/sdk/src/node.ts The code changes introduce support for importing remote files in ESM format in the Node.js environment. The primary modifications include adding a new function loadModule that handles the loading and evaluation of ESM modules, and updating the createScriptNode function to support ESM scripts by leveraging the loadModule function.

Copy link
Contributor

@squadronai squadronai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incremental Review

Comments posted: 7

Configuration

Squadron Mode: essential

Commits Reviewed

64c98f1384aed95f9a7d6efe8c9ddf7db2bde4bc...f26ad72e03de69e9b9795fb07614865dfb71e61c

Files Reviewed
  • packages/runtime/src/plugins/generate-preload-assets.ts
  • packages/runtime/src/utils/load.ts
  • packages/sdk/src/dom.ts
  • packages/sdk/src/generateSnapshotFromManifest.ts
  • packages/sdk/src/node.ts
Files Ignored

These files were ignored due to the filter in the squadron.yaml file.

  • .github/workflows/release.yml
  • package.json
  • pnpm-lock.yaml

@module-federation module-federation deleted a comment from squadronai bot Sep 29, 2024
@module-federation module-federation deleted a comment from squadronai bot Sep 29, 2024
@module-federation module-federation deleted a comment from squadronai bot Sep 29, 2024
@module-federation module-federation deleted a comment from squadronai bot Sep 29, 2024
@module-federation module-federation deleted a comment from squadronai bot Sep 29, 2024
@module-federation module-federation deleted a comment from squadronai bot Sep 29, 2024
@module-federation module-federation deleted a comment from squadronai bot Sep 29, 2024
@ScriptedAlchemy ScriptedAlchemy merged commit d018704 into main Sep 29, 2024
17 checks passed
@ScriptedAlchemy ScriptedAlchemy deleted the feature/node-esm branch September 29, 2024 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants